#!/usr/bin/env python
# -*- coding=utf-8 -*-
"""
@author: xingwg
@license: (C) Copyright 2020-2025.
@contact: xingweiguo@chinasvt.com
@project: boya-reid
@file: make_data.py
@time: 2020/9/23 22:44
@desc: 整合2020和2019数据
    计划：
    1. 训练数据命名，年代_标签_图片名
    2. 在2020训练数据中随机分出500ID作为测试集
"""
import os
import shutil
import tqdm

naic_dir = "/raid/xingwg/naic/"

image_lists = os.listdir(naic_dir + "train")

f = open(naic_dir + "train_list.txt", "w")
for img_name in tqdm.tqdm(image_lists):
    year, label, name = img_name.split("_")
    if year == "2019":
        label = int(label) + 50000

    f.write("train/{} {}\n".format(img_name, label))
f.close()


# naic_dir_2020 = "/home/svt/workspace/PCLDataset/train/naic_2019"
#
# if not os.path.exists(naic_dir):
#     os.makedirs(naic_dir)
#
# # step1 随机分离500ID作为测试集
# f = open(os.path.join(naic_dir_2020, "train_list_b.txt"), "r")
# lines = f.readlines()
# f.close()
#
# for line in tqdm.tqdm(lines):
#     img_name, label = line.strip().split()
#     img_path = os.path.join(naic_dir_2020, img_name)
#     if not os.path.exists(img_path):
#         print("{} not exist".format(img_path))
#         continue
#
#     new_name = "2019_{}_{}.png".format(label, img_name.split("/")[-1].split(".")[0])
#
#     new_path = os.path.join(naic_dir, new_name)
#     if os.path.exists(new_path):
#         print("{} already exist".format(img_path))
#         continue
#
#     shutil.copy(img_path, new_path)









